//
//  OrderListCell.m
//  Recipe
//
//  Created by bing han on 12-7-12.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "OrderListCell.h"
#define ADDTAG 10000
#define REMOVETAG 20000
#define DELETETAG 30000

@implementation OrderListCell
@synthesize lblIndex = _lblIndex, lblname = _lblname, require = _require, price = _price, unit = _unit, count = _count;
@synthesize addBtn = _addBtn, removeBtn = _removeBtn, deleteBtn = _deleteBtn;

@synthesize delegate;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void) setCellWithDictionary:(NSDictionary*) disherOrder{
    _lblIndex.text = [disherOrder objectForKey:@"index"];    
    _lblname.text =  [disherOrder objectForKey:@"cnamecn"];
    _price.text = [disherOrder objectForKey:@"cprice"];
    _require.text = [disherOrder objectForKey:@"require"];
    _count.text = [disherOrder objectForKey:@"count"];
    _unit.text = [disherOrder objectForKey:@"unit"];
    _addBtn.tag = ADDTAG + [[disherOrder objectForKey:@"index"] intValue];
    _removeBtn.tag = REMOVETAG + [[disherOrder objectForKey:@"index"] intValue];
    _deleteBtn.tag = DELETETAG + [[disherOrder objectForKey:@"index"] intValue];
}

-(IBAction) addDisher:(id)sender{
    UIButton *tmpbtn = (UIButton *) sender;
    int tag = tmpbtn.tag;
    tag -= ADDTAG + 1;
    [delegate addDisher:tag];
}
-(IBAction) removeDisher:(id)sender;{
    UIButton *tmpbtn = (UIButton *) sender;
    int tag = tmpbtn.tag;
    tag -= REMOVETAG + 1;
    [delegate removeDisher:tag];
}
-(IBAction) deleteDisher:(id)sender;{
    UIButton *tmpbtn = (UIButton *) sender;
    int tag = tmpbtn.tag;
    tag -= DELETETAG + 1;
    [delegate deleteDisher:tag];
}
@end
